package com.cntcdt.api.db.dao;

import java.util.List;

import com.cntcdt.api.db.dao.base.TicketTypeDaoBase;
import com.cntcdt.api.db.model.TicketTypeModel;

/**
 * 这是cdt_ticket_type的Dao实现类
 */
public class TicketTypeDao extends TicketTypeDaoBase {
	/**
	 * TicketTypeDao对象
	 */
	private static TicketTypeDao instance = new TicketTypeDao();

	/**
	 * 默认构造方法
	 */
	private TicketTypeDao() {
	}

	/**
	 * 获得对象实例
	 */
	public static TicketTypeDao getInstance() {
		return instance;
	}

	/**
	 * 按type查询model
	 * 
	 * @param id
	 *            id
	 * @return model
	 */
	public TicketTypeModel findByType(Integer type) {
		String sql = "SELECT * FROM " + TABLE + " WHERE type = ?";
		Object[] paramObjs = { type };
		List<TicketTypeModel> modelList = this.queryModelList(sql, paramObjs);
		if (modelList != null && modelList.size() > 0) {
			return modelList.get(0);
		}
		return null;
	}

	/**
	 * 查询所有线
	 * 
	 * @return
	 */
	public List<TicketTypeModel> getAllTicketModel() {
		String sql = "select * from " + TABLE;
		List<TicketTypeModel> modelList = this.queryModelList(sql);
		return modelList;
	}
}
